try { var dummy = RoomSizeLimiter; } catch ( e ) {

/** Limits the number of authorized users that can connect to an application instance. */
function RoomSizeLimiter(){
	// Do nothing. Use the init method instead.
}

// Required for AS 1 inheritance.
RoomSizeLimiter.prototype = new RTCFComponent();

/** Setup initial values and listeners. */
RoomSizeLimiter.prototype.init = function(){
	this.maxUsers = 4;
	this.currentUsers = 0;
	this.rtcf.addListener("onAuthenticate", this);
	this.rtcf.addListener("onAuthorizedConnect", this);
	this.rtcf.addListener("onAuthorizedDisconnect", this);
}

/** If there is enough room authenticate the user, otherwise rejet them.*/
RoomSizeLimiter.prototype.onAuthenticate = function(client, user){
	if (this.currentUsers < this.maxUsers){
		this.rtcf.authorizationResult(client, user); 
	}
	else{
		this.rtcf.authorizationFault(client, "Too many users. Can't accept any more."); 
	}
}

/** Count each newly accepted user. */
RoomSizeLimiter.prototype.onAuthorizedConnect = function(client, user){
	this.currentUsers++;	
}

/** Count each user that leaves. */
RoomSizeLimiter.prototype.onAuthorizedDisconnect = function(client, user){
	this.currentUsers--;
}

} // end catch
